package com.blog.controller;

import com.blog.Utils.Result;
import com.blog.annotion.LoginAnnotatio;
import com.blog.base.ThreadLocalUserId;
import com.blog.bean.dto.MessageDTO;
import com.blog.bean.vo.MessageDetailVO;
import com.blog.webSocket.service.ChatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 任浩
 * @version 1.0
 */

@Slf4j
@RestController
@RequestMapping("/chatMessage")
public class ChatMessageController {

    @Autowired
    private ChatService chatService;

    @GetMapping
    @LoginAnnotatio
    public Result<MessageDetailVO> getChatMessage(MessageDTO messageDTO){
        String userId = ThreadLocalUserId.get();
        Result<MessageDetailVO> recentChatRecords = chatService.getRecentChatRecords(userId, messageDTO);
        return recentChatRecords;
    }

}
